<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>2014年到2050年哪年一月一日是星期日</title>
</head>

<body>
  <script>
    let endDate14 = (new Date('2014-1-1')).getTime();
    let newDate14 = new Date(endDate14)
    let endDate50 = (new Date('2050-1-1')).getTime();
    let newDate50 = new Date(endDate50)
    console.log(newDate14)
    console.log(newDate50)
    week = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六',]
    // //2014年的转化时间
    timeN14 = newDate14.getFullYear()
    timeY14 = newDate14.getMonth() + 1 // 1
    timeR14 = newDate14.getDate() // 1
    timeW14 = newDate14.getDay() // 2014/1/1 的日期
    hh14 = timeN14 + ':' + timeY14 + ":" + timeR14
    console.log(hh14)
    // //2050年的转化时间
    timeN50 = newDate50.getFullYear()
    timeY50 = newDate50.getMonth() + 1
    timeR50 = newDate50.getDate()
    timeW50 = newDate50.getDay() // 2050/1/1 的日期
    hh50 = timeN50 + ':' + timeY50 + ":" + timeR50
    console.log(hh50)
    for (let i = timeN14; i <= timeN50; i++) {
      let time14X = new Date(timeN14, timeY14, timeR14)
      if (week[time14X.getDay()] == '星期日') {
        console.log(timeN14, week[time14X.getDay()])
      }
      ++timeN14
    }
  </script>
</body>

</html>